//
//  TravelTableViewCell.m
//  Fangmm
//
//  Created by ChaoZhou on 16/3/7.
//  Copyright © 2016年 com.fangmm. All rights reserved.
//

#import "TravelTableViewCell.h"
#import <UIImageView+WebCache.h>
@implementation TravelTableViewCell


- (void)awakeFromNib
{
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
-(void)configScheduleCellWithIndexpath:(NSIndexPath*)indexpath WithSchedule:(Schedule*)schedule
{
    NSMutableArray *priceArray = [NSMutableArray array];
    NSLog(@"%lu",(unsigned long)schedule.menberArray.count);
    for (HomePageUser *user in schedule.menberArray)
    {
        int price = user.rent;
        [priceArray addObject:[NSString stringWithFormat:@"%d",price]];
    }
    NSLog(@"+++%@",(House *)schedule.scheduleArray[0]);
    House *house = (House*)(schedule.scheduleArray[indexpath.section - 1]);
    if (house.major == YES)
    {
        self.titleLabel.textColor = [UIColor colorWithRed:255.0/255 green:118.0/255 blue:108.0/255 alpha:1];
        self.titleLabel.text = @"成团房源";
    }
    else if(house.major == NO)
    {
        self.titleLabel.textColor = [UIColor colorWithRed:160.0/255 green:160.0/255 blue:160.0/255 alpha:1];
        self.titleLabel.text = @"备看房源";
    }
    [self.houseImage sd_setImageWithURL:[NSURL URLWithString:house.houseCover] placeholderImage:[UIImage imageNamed:@"datail_house"]];
    self.houseName.text = house.houseCommunity;
    self.communityLabel.text = house.houseCommunity;
    NSString *houseStyleStr = [NSString stringWithFormat:@"%d室%d厅%d卫",house.houseRoomNum,house.houseHallNum,house.houseToiletNum];
    self.houseNumLabel.text = houseStyleStr;
    self.areaLabel.text = [NSString stringWithFormat:@"%@",house.houseArea];
    self.seeTimeLbel.text = house.meetingTime;
    self.meetPlaceLabel.text = house.meetingSite;
    self.leadingManLabel.text = house.meetingPeople;
    switch (_scheduleInfo.menberArray.count)
    {
        case 0:
        {
            self.roomAPrice.hidden = YES;
            self.roomBPrice.hidden = YES;
            self.roomCPrice.hidden = YES;
        }
            break;
        case 1:
        {
            self.roomAPrice.hidden = NO;
            self.roomAPrice.text   = priceArray[0];
            self.roomBLabel.hidden = YES;
            self.roomBPrice.hidden = YES;
            self.roomCLabel.hidden = YES;
            self.roomCPrice.hidden = YES;
        }
            break;
        case 2:
        {
            self.roomAPrice.hidden = NO;
            self.roomAPrice.text = priceArray[0];
            self.roomBLabel.text = priceArray[1];
            self.roomBPrice.hidden = NO;
            self.roomCLabel.hidden = YES;
            self.roomCPrice.hidden = YES;
        }
            break;
        case 3:
        {
            self.roomAPrice.hidden = NO;
            self.roomBPrice.hidden = NO;
            self.roomCPrice.hidden = NO;
            self.roomAPrice.text = priceArray[0];
            self.roomBPrice.text = priceArray[1];
            self.roomCPrice.text = priceArray[2];
        }
            break;
        default:
        {
            
        }
            break;
    }
    
}

- (IBAction)locationBtn:(id)sender
{
    [self.delegate popToMapViewWithsender:sender];
}

- (IBAction)callBtn:(id)sender
{
    NSMutableArray *tellArray = [NSMutableArray array];
    for (House *house in self.scheduleInfo.scheduleArray)
    {
        [tellArray addObject:house.meetingMobile];
    }
    if ([tellArray[self.indexpath.section - 1] isEqualToString:@""])
    {
        NSLog(@"00000");
    }
    else
    {
        NSString *allString = [NSString stringWithFormat:@"tel:%@",tellArray[self.indexpath.section - 1]];
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:allString]];
    }
}
@end
